19. Exercise: Caching with Loaders

Let's cache our Loader result, preventing queries just because the user navigated away from the app. Follow the TODOs in the following exercise.

Exercise Code

Exercise: T05b.03-Exercise-PolishAsyncTask

Caching with Loaders in Github Query

SOLUTION:
  • Create a member variable to store the cached result in
  • Modify onStartLoading to just call deliverResult if the cache isn't null
  • Override deliverResult to store the data in our cache member variable